home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Chat & Communication
/
Digsby build 37
/
digsby_setup.exe
/
lib
/
gui
/
chevron.pyo
(
.txt
)
< prev
next >
Wrap
Python Compiled Bytecode
|
2008-10-13
|
4KB
|
111 lines
# Source Generated with Decompyle++
# File: in.pyo (Python 2.5)
import wx
from gui.textutil import GetTextWidth
from gui import skin
from gui.toolbox import prnt
from cgui import SimplePanel
from config import platformName
class Chevron(SimplePanel):
def __init__(self, parent, label = '', callapsedicon = None, expandedicon = None):
SimplePanel.__init__(self, parent)
if not callapsedicon:
pass
self.callapsedicon = skin.get('AppDefaults.icons.chevroncolapsed')
if not expandedicon:
pass
self.expandedicon = skin.get('AppDefaults.icons.chevronexpanded')
self.Label = label
self.CalcSize()
self._expanded = False
self.isdown = False
Bind = self.Bind
Bind(wx.EVT_PAINT, self.OnPaint)
Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
Bind(wx.EVT_LEFT_DCLICK, (lambda e: pass))
def CalcSize(self):
iwidth = max([
self.callapsedicon.Width,
self.expandedicon.Width])
iheight = max([
self.callapsedicon.Height,
self.expandedicon.Height])
self.iconspace = wx.Size(iwidth, iheight)
fwidth = GetTextWidth(self.Label, self.Font)
fheight = self.Font.Height
self.MinSize = wx.Size(iwidth + fwidth + 12, max([
iheight,
fheight]) + 6)
def GetExpanded(self):
return self._expanded
def SetExpanded(self, expand):
self._expanded = expand
e = wx.CommandEvent(wx.wxEVT_COMMAND_CHECKBOX_CLICKED)
e.EventObject = self
e.SetInt(expand)
self.AddPendingEvent(e)
self.Refresh()
Expanded = property(GetExpanded, SetExpanded)
def OnPaint(self, event):
dc = wx.PaintDC(self)
rect = wx.RectS(self.Size)
if platformName != 'mac':
dc.Brush = wx.Brush(self.BackgroundColour)
dc.Pen = wx.TRANSPARENT_PEN
dc.DrawRectangleRect(rect)
dc.Font = self.Font
(iwidth, iheight) = self.iconspace
icon = None if self.Expanded else self.callapsedicon
dc.DrawBitmap(icon, (iwidth // 2 - icon.Width // 2) + 3, (iheight // 2 - icon.Height // 2) + 3, True)
textrect = wx.Rect(iwidth + 9, 0, rect.width - iwidth + 9 - 3, rect.height)
dc.DrawLabel(self.Label, textrect, wx.ALIGN_LEFT | wx.ALIGN_TOP)
def OnLeftDown(self, event):
self.isdown = True
def OnLeftUp(self, event):
if self.isdown:
self.Expanded = not (self.Expanded)
self.isdown = False
self.Refresh()
class F(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None)
S = self.Sizer = wx.BoxSizer(wx.VERTICAL)
p = self.panel = wx.Panel(self)
S.Add(p, 1, wx.EXPAND)
s = p.Sizer = wx.BoxSizer(wx.VERTICAL)
chev = self.chev = Chevron(p, 'Expand')
chev.Bind(wx.EVT_CHECKBOX, (lambda e: prnt('clixxd', e.IsChecked())))
s.Add(chev, 0, wx.ALL, 10)
if __name__ == '__main__':
from tests.testapp import testapp
hit = wx.FindWindowAtPointer
a = testapp('../../')
f = F()
f.Show(True)
a.MainLoop()